<?php session_start() ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>KAR Events</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<? include("./includes/head.inc");  ?>
<style type="text/css">
<!--

.style5 {color: #FF0000}
.style8 {color: #999999; }
.style15 {color: #000000; }
.style20 {font-size: 14px; color: #000000; }
.style22 {font-size: 14px}
.style24 {
	color: #FF0000;
	font-size: 1.2em;
}
.style27 {font-weight: bold}
.style29 {color: #000000; font-weight: bold; }
.style30 {color: #0000CC}
.style31 {color: #FF003A}
.style33 {
	font-size: 24pt;
	font-family: "Courier New", Courier, monospace;
}
.style34 {font-size: 24pt; font-family: "Courier New", Courier, monospace; font-weight: bold; }

-->

</style>
</head>

<body>
<!--initial body width and height set up  -->
<div id="bodywidth">
<? include("./includes/header.inc");  ?>
<? include("./includes/leftmenu.inc");  ?>

<div id="wide2column"><!--begin body of page column 2-->
<!--***********IMPORTANT************************************************IMPORTANT******-->
<!-- DO NOT CHANGE ANYTHING ABOVE THIS LINE EXCEPT THE "TITLE"-->

<p style="text-align: center"><b><font size="5"><BR>Upcoming Events </font></b></p>

<?php

include("./db.php");
				// Connect to the database server
dbConnect('kar_web1');   	// Use function in db.php to connect

$result = @mysql_query("SELECT *
						FROM locations") or
			die("Error getting events. ".mysql_error());

echo("&nbsp;<TABLE cellpadding=0 cellspacing=0>");

$num_rows = mysql_num_rows($result);

echo("<table width=\"99%\" border=\"0\" cellpadding=\"5\">");
            
while ( $row = mysql_fetch_array($result) ) {
	$location = $row["name"];
	$ID = $row["location_id"];
    $friendly = $row["friendly_address"];
    $map = $row["map"];
    $logo = $row["logo_url"];
    
    if(($ID == 3)||($ID == 4)) {
    	$location = substr($location, 0, 17);
    }

	$event_query = @mysql_query("SELECT *
    							FROM events
                                WHERE eventDate >= current_date AND eventDate < ADDDATE( current_date, 30 )
                                AND location_id = ".$ID) or
				die("Error getting events. ".mysql_error());

	$num_of_events = mysql_num_rows($event_query);
    
    if( $num_of_events > 0) {
        echo("<tr><td width=\"73%\"><h4 align=\"left\"><span class=\"style5\">".$location." on ".$friendly);
        if($map != "") {
        	echo(" <a href=".$map.">Map</a>\n");
        }
        echo("</span></h4>");
        while( $event = mysql_fetch_array($event_query) ) {
        	$event_ID = $event["eventID"];
            $date = $event["eventDate"];
        	
            $BTime =  $event["eventBeginTime"];
			list($Bhour, $Bmin, $Bsec) = explode(":", $BTime);
			$BeginTime = date("ga", mktime($Bhour, $Bmin));
	
			$ETime =  $event["eventEndTime"];
			list($Ehour, $Emin, $Esec) = explode(":", $ETime);
			$EndTime = date("ga", mktime($Ehour, $Emin));

	       	list($year, $month, $day)  = explode("-", $event["eventDate"]);
    		$eventDate = date("F jS", mktime(0,0,0,$month, $day,$year));            
            
            echo("<p class=\"style15\"><strong><strong>".$eventDate."</strong>\t (".$BeginTime." - ".$EndTime.")\t<a href=http://02d2e0a.netsolhost.com/phpprod/sched2.php?eventID=".$event_ID.">See the scheduled pets</a>\n");
        }
        echo("<hr class=\"thickline\"/></td>\n");
        echo("<td><img src=".$logo." /></td>");
    }
    echo("</tr>");
}
echo("</TABLE>");
?>
<p><BR>
    </div>

<? include("./includes/footer.inc");  ?>

<!--tag below ends bodywidth div -->

</div>
</body>
</html>